using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;


namespace IQIGame.Onigao.GamePlay
{
    public class UILoading : UIEntityWindow
    {
        /// <summary>
        /// 静态配置
        /// </summary>
        private static UICreateConfig _createConfig = new()
        {
            prefabName = nameof(UILoading),
            layer = EUILayer.Loading,
            permanent = true,
        };

        /// <summary>
        /// 创建UI的配置
        /// </summary>
        public override IUICreateConfig createConfig => _createConfig;

        #region Template Generate,don't modify
        protected partial class UIB_UILoading
        {
            #region ObjectBinding Generate 
            public IQIGame.Onigao.Framework.ExImage imageProgress { protected set; get; }
            public IQIGame.Onigao.Framework.ExText text { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExImage>("imageProgress", out var __tbv0);
                this.imageProgress = __tbv0;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("text", out var __tbv1);
                this.text = __tbv1;
            }

            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify


        protected UIB_UILoading ui { get; set; }

        protected override void BeforeInit()
        {
            ui = new UIB_UILoading();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {
        }

        protected override void OnShow(UIBaseData data)
        {

        }

        protected override void OnHide()
        {

        }

        public void UpdateLoadingProgress(float ratio)
        {
            this.ui.imageProgress.fillAmount = ratio;
        }

        protected override void OnDispose()
        {

        }
    }
}
